#! /usr/bin/perl

use strict;
use diagnostics;
use threads;

sub myWait {

	sleep( $_[0] );
}

my $thr;
for ( my $i = 0 ; $i <= 10 ; $i++ ) {
	$thr = threads->create( 'myWait', '10' );
}

$thr->detach();
printf "detached: [%d]\n", $thr->tid();
for $thr (threads->list()){
	printf "$thr has tid = %d\n", $thr->tid();
	$thr->detach();
}
sleep(8);

$thr = threads->object(2);
my $result = $thr->is_running();
printf "[$result][%d]\n", $thr->tid();
sleep(3);
$result = $thr->is_running();
print "[$result]\n";
